﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Payroll.PayrollConstants;
using static Modules.Person.PersonConstants;

namespace Modules
{
    /// <summary>
    /// 工资单明细
    ///</summary>
    [TableName("wage_payroll_detail")]
    [Description("工资单明细")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, PropertyNamesOfArea = "PayrollId,PersonId")]
    [Serializable]
    public class WagePayrollDetail : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 发放月份
        ///</summary>
        [Column("month")]
        public int Month { get; set; }

        /// <summary>
        /// 项目Id
        ///</summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 工资单Id
        ///</summary>
        [Column("payroll_id")]
        public int PayrollId { get; set; }

        /// <summary>
        /// 班组Id
        ///</summary>
        [Column("group_id")]
        public int GroupId { get; set; }

        /// <summary>
        /// 成员ID
        /// </summary>
        [Column("member_id")]
        public int MemberId { get; set; }

        /// <summary>
        /// 工种
        ///</summary>
        [Column("work_type")]
        public 工人工种? WorkType { get; set; }

        /// <summary>
        /// 人员id
        ///</summary>
        [Column("person_id")]
        public int PersonId { get; set; }

        /// <summary>
        /// 人员姓名
        ///</summary>
        [Column("person_name")]
        public string PersonName { get; set; }

        /// <summary>
        /// 人员身份证号码
        ///</summary>
        [Column("idcard")]
        public string IdCard { get; set; }


        /// <summary>
        /// 人员银行卡号
        ///</summary>
        [Column("bank_card_no")]
        public string BankCardNo { get; set; }

        /// <summary>
        /// 开户行
        /// </summary>
        [Column("bank_name")]
        public string BankName { get; set; }

        /// <summary>
        /// 考勤天数
        ///</summary>
        [Column("attendance_days")]
        public decimal? AttendanceDays { get; set; }

        /// <summary>
        /// 申请金额
        ///</summary>
        [Column("amount_applied")]
        public decimal? AmountApplied { get; set; }

        /// <summary>
        /// 实发金额
        ///</summary>
        [Column("amount_paid")]
        public decimal? AmountPaid { get; set; }

        /// <summary>
        /// 状态(1 :已发  0 未发)
        ///</summary>
        [Column("status")]
        public 工资发放状态 Status { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 发放时间
        ///</summary>
        [Column("issue_time")]
        public DateTime? IssueTime { get; set; }

        /// <summary>
        /// 代发失败原因
        /// </summary>
        [Column("fail_reason")]
        public string FailReason { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.Id; } }

        #endregion IEntity 成员
    }
}